import VeeValidate, { Validator } from 'vee-validate';
import Vue from 'vue';
Vue.use(VeeValidate, {
  locale: 'zh_CN'
});
Validator.localize('zh_CN');
Validator.localize({
  zh_CN: {
    messages: {
      required: function(name) {
        return '请输入' + name;
      }
    }
  }
});
Validator.extend('phone', {
  getMessage: function() {
    return '手机号格式错误';
  },
  validate: function(value) {
    return /^1[3456789][0-9]{9}$/.test(value);
  }
});
Validator.extend('captcha', {
  getMessage: function() {
    return '请输入6位有效验证码';
  },
  validate: function(value) {
    return /^[0-9]{6}$/.test(value);
  }
});
Validator.extend('loginPassword', {
  getMessage: function() {
    return '为了您的账户安全，密码须为6-12位数字与字母的组合';
  },
  validate: function(value) {
    return /^(?!([a-zA-Z]+|\d+)$)[a-zA-Z\d]{6,12}$/.test(value);
  }
});
Validator.extend('loginPassword2', {
  getMessage: function() {
    return '请输入正确的6-12位数字与字母的密码';
  },
  validate: function(value) {
    return /^(?!([a-zA-Z]+|\d+)$)[a-zA-Z\d]{6,12}$/.test(value);
  }
});
Validator.extend('payPassword', {
  getMessage: function() {
    return '为了您的账户安全，支付密码须为6位数字密码';
  },
  validate: function(value) {
    return /^[0-9]{6}$/.test(value);
  }
});
